package com.nancy.springioc.business.controller;


import com.nancy.springioc.business.service.GoodsService;
import com.nancy.springioc.context.support.ClassPathXmlApplicationContext;

/**
 * 通过自定义spring ioc容器框架，实现bean的创建和注入
 */
public class GoodsController {
    public static void main(String[] args) throws Exception {
//        InputStream inputStream = GoodsController.class.getClassLoader().getResourceAsStream("applicationContext.xml");
//        if (inputStream == null) {
//            System.out.println("File not found");
//        } else {
//            System.out.println("File found");
//        }


        //1.创建自定义spring ioc容器
        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        //2.获取bean,GoodsServiceImpl对象
        GoodsService goodsService = classPathXmlApplicationContext.getBean("goodsService", GoodsService.class);
        // 3.调用方法
        goodsService.save();
    }
}
